<template>
  <div>
    <el-divider></el-divider>
    <div style="font-size:20px;text-align:left">
      <i class="el-icon-document-checked">窗口退号</i>
    </div>
    <el-divider></el-divider>
    <el-row :gutter="20">
      <el-col :span="6"><el-input v-model="case_number" placeholder="请输入患者病历号"></el-input></el-col>
      <el-col :span="6"><el-input v-model="real_name" placeholder="请输入患者姓名"></el-input></el-col>      
      <el-col :span="2"><el-button @click="getWaitPatient(1)">搜索</el-button></el-col>
      <el-col :span="10"> </el-col>
    </el-row>
    <el-divider></el-divider>
    <el-table
      :data="wait_patient"      style="width: 80%">
      <el-table-column        type="index"     label="编号"        width="80"></el-table-column>
      <el-table-column        prop="case_number"        label="患者病历号">      </el-table-column>
      <el-table-column        prop="real_name"        label="患者姓名"        width="180"></el-table-column>      
      <el-table-column        prop="gender"        label="性别"        width="80"></el-table-column>
      <el-table-column        prop="card_number"        label="身份证号"        width="240"></el-table-column>
      <el-table-column        prop="regist_method"        label="付款方式"        width="180"></el-table-column>
      <el-table-column label="操作">
      <template slot-scope="scope">
        <el-button   size="mini" @click="refundMedicalRecord(scope.$index, scope.row)">退号</el-button>
      </template>
    </el-table-column>
    </el-table>
    <el-divider></el-divider>
    <el-pagination
    :page-size="pageSize" :total="totalCount" @current-change="wait_patient_table_change"
    layout="prev, pager, next">
  </el-pagination>
  </div>
</template>
<script>
    export default {
      data() {
        return {
          case_number:'',
          real_name:'',
          pageSize:10,//每页显示行数
          totalCount:0,
          employee_id:1,//当前医生的id
          wait_patient: []
        }
      },
      methods:{
        //退号
        refundMedicalRecord(scope_index,scope_row){
          let id = this.wait_patient[scope_index].id;
          this.$http.get("http://localhost:8092/refundMedicalRecord?id="+id).then(
            (resp)=>{
              this.$message('退号患者：'+ this.wait_patient[scope_index]["real_name"]);
              this.getWaitPatient(1);
            }
          )      
          
        },
        //等待患者table数据改变时触发的事件
        wait_patient_table_change(nowPageNumber){
          this.getWaitPatient(nowPageNumber);
        },
        //得到等待看诊患者信息
        getWaitPatient(nowPageNumber){
          this.$http.get("http://localhost:8092/getRecordRefundPatient?case_number="+this.case_number
            +"&real_name="+this.real_name
            +"&nowPageNumber="+nowPageNumber
            +"&pageSize="+this.pageSize).then(
            (resp)=>{
              this.wait_patient = resp.data.list;
              this.totalCount = resp.data.totalCount;
            }
          )
        }
      },
      mounted:function(){        
        //得到等待看诊患者信息
        this.getWaitPatient(1);
      }
    }
  </script>